#!/usr/bin/perl -w # for syntax highlighting
use gri_database;

sub mm_form_useralert_populate {

	#############################################################
	# Query the authentication daemon to get a list of users.	#
	#############################################################
	my $users=$::GRI_FRONTEND->query_authd("GET_USER_LIST");
	if(!defined($users)) {
		print STDERR "Error: mm_form_useralert_populate :: GET_USER_LIST request errored!\n";
		return "Error: mm_form_useralert_populate :: GET_USER_LIST errored!";
	} 
	
	my $row=0; my $col=0;
	$s.="<tr class=gri_headerrow>
  <td class=gri_cell>User ID</td>
  <td class=gri_cell>User Name</td>
  <td class=gri_cell-right>Action</td></tr>\n";
	
	my @L=split(/\n/,$users);
	@L=sort {my @a2=split(/\|/,$a); my @b2=split(/\|/,$b); $a2[1] cmp $b2[1]} @L[1 .. $#L];
	$row=0;
	for my $crep (@L) {
		my $class="gri_odd";
		$class="gri_even" if $row%2==0;
		$row++;
		my ($uid,$name)=split(/\|/,$crep);
		$u2=string_to_hex($uid);
		my $l=link_to_str("stdlink","Modify","form_modify_user_alerting","user=$u2");
		$s.="<tr id=$class><td class=gri_cell>$uid</td><td class=gri_cell>$name</td><td class=gri_cell-right>$l</td></tr>\n";
	}
	return $s;
}

1;

# vim: ts=4:sw=4
